package com.pei.controller;

import com.pei.exception.MyException;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.ArrayList;
@Controller
public class ExceptionController {
    @RequestMapping("/showNullPointer")
    public void showNullPointer(){
//        ArrayList<Object> list = new ArrayList<>();
//        System.out.println(list.get(2));
        String str = null;
        System.out.println(str.charAt(0));
    }

    @RequestMapping("/showIOException")
    public void showIOException() throws FileNotFoundException {
        FileInputStream in = new FileInputStream("JavaWeb.xml");
    }

    @RequestMapping("/showArithmetic")
    public void showArithmetic(){
        int c=1/0;
    }

    @RequestMapping("addData")
    public void addData() throws MyException{
        throw new MyException("新异常");
    }
}
